/**
 * \file Symbol.h
 *
 * Asteriskos Compiler 1
 * Written 2010-2011, by Anthony Berlin and Alexander Carlqvist
 *
 * This file is part of ICC.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __SYMBOL_H__
#define __SYMBOL_H__

class Token;
class Tree;
class SymbolTable;

#include "Token.h"
#include "SymbolType.h"
#include "Tree.h"

#include <GCB/Object.h>
#include <GCB/Datatype.h>

class Symbol : public Object
{
public:
    /// Constructor for 'Symbol'.
    Symbol();

    /// Print s human readable string representation of this symbol.
    string to_string() const;

    /// Which type of symbol this is.
    SymbolType m_type;

    /// The token associated with this symbol.
    Token* m_token;

    /// The parent scope of this symbol. This is the scope where this symbol was declared.
    SymbolTable* m_parent;

    /// This is the own scope for this symbol. This is used by functions, for example, to
    /// give them their own scope.
    SymbolTable* m_ownScope;

    /// The datatype of the symbol.
    Datatype* m_datatype;

    /// The tree that "declared" this symbol.
    Tree* m_tree;

    /// The tree of the definition, if one exists (the rvalue for variables, function bodies are
    /// not assigned to this data member).
    Tree* m_definition;

    /// True if this is a parameter declaration.
    bool m_isParamDecl;

    /// Modifiers.
    bool m_modConst;
    bool m_modExtern;
    bool m_modStatic;

    /// This is set to true if this function only contains one statement that is not a compound-
    /// statement, and if that one statement is a return-statement.
    bool m_isEvaluable;

    /// True if it has already been defined (except if this is a variable).
    bool m_isDefined;
};

#endif  //__SYMBOL_H__
